package com.cneiu.ppms.web.action;


import com.cneiu.ppms.web.base.BaseController;
import com.cneiu.ppms.web.model.JobModel;
import com.cneiu.ppms.web.service.JobService;
import com.jfinal.plugin.activerecord.Page;

/**
 * 岗位的控制器Controller
 * @author zhaokf
 * @date 2013-04-15
 */
public class JobController extends BaseController
{
	/**
	 * 获取page limit得到岗位列表
	 */
	public void list(){
	
		Page<JobModel> Jobs = JobService.list(this.getParams());
		if (null != Jobs){
			renderGrid(Jobs.getTotalRow(), Jobs.getList());
		}else{
			renderAjax(false, JobService.getError());
		}
	}

	/**
	 * 添加岗位
	 */
	public void add(){
		try{
			boolean isNotError = true;
			if (!JobService.isAdd(this.getParams())){
				isNotError = false;
			}
			renderAjax(isNotError, JobService.getError());
		}
		catch (Exception e){}

	}

	/**
	 * 编辑岗位
	 */
	public void edit(){
		try{
			boolean isNotError = true;
			if (JobService.isUpdate(this.getParams())){
				isNotError = false;
			}
			renderAjax(isNotError, JobService.getError());
		}
		catch (Exception e){}
	}
	
	/**
	 * 删除岗位
	 */
	public void delete(){
		try{
			boolean isNotError = true;
			if (JobService.isDelete(this.getParams())){
				isNotError = false;
			}
			renderAjax(isNotError, JobService.getError());
		}
		catch (Exception e){
		}
	}
}
